package org.batatasframework.support.database.sql.field;

import java.util.List;

import org.batatasframework.support.database.metadatas.FieldMetadata;
import org.batatasframework.support.database.sql.TableRuntimeMaster;
import org.batatasframework.support.database.sql.TableInstance;


public abstract class MultipleSelectFragment extends AbstractMultipleSelectFragment<FieldElement>{

	public MultipleSelectFragment(TableRuntimeMaster master, String title) {
		super(master, title);
	}

	@Override
	protected FieldElement _buildField(TableInstance tableSource, FieldMetadata fieldMetadata) {
		return master.loadFieldElement(tableSource, fieldMetadata);
	}

	@Override
	public FieldMetadata find(String name) {
		for(FieldElement fr : fields){
			if(name.equals(fr.getName())){
				return fr;
			}
		}
		return null;
	}

	@Override
	public void readSource(List<FieldMetadata> fields) {
		for(FieldElement fr : this.fields){
			fields.add(fr);
		}
	}
}
